#!/usr/bin/env python3
'''
Created on May 29, 2013

@author: Brieg
'''
from tkinter import *
import time
from Placard.Animal import *

def dessinerLignes(canvas):
    canvas.create_line(0,0,400,0,fill = "black")
    canvas.create_line(400,0,400,400,fill = "black")
    canvas.create_line(400,400,0,400,fill = "black")
    canvas.create_line(0,400,0,0,fill = "black")
    return

def dessinerCases(canvas):
    for y in range(0,500,100):
        for x in range(0,500,100):        
            canvas.create_rectangle(x,y,x + 50,y + 50,fill = "dark grey")
    for y in range(50,500,100):
        for x in range(50,500,100):        
            canvas.create_rectangle(x,y,x + 50,y + 50,fill = "dark grey")        
    return

def dessineEtre(canvas,a):
    canvas.create_text((a.position[0]*50)+25,(a.position[1]*50)+25,text=a.text)
    
def deroulement(canvas,a,c,s):  
    dessineEtre(canvas,a)
    dessineEtre(canvas,c)
    a.action(s)
    c.action(s)

def clearScreen(canvas):
    canvas.create_rectangle(0,0,500,500,fill = "white")   
      
###############Main Loop#####################
plateau = Tk()
plateau.title("Biome V0")
board = Canvas(plateau,width =500,height=500,bg ="white")
board.pack()
###############Gui management#################

s = Savanne()
a1 = Animal(1,2,[1,0],"A1")
a2 = Animal(2,2,[2,2],"A2")
s.Savane[1][0][1]= a1
s.Savane[2][2][1]= a2


#dessinerLignes(board)
while(True):
    clearScreen(board)
    dessinerCases(board)
    deroulement(board,a1,a2,s)
    print("===========")
    time.sleep(1)
    
    board.update()
    
plateau.mainloop()
    
    
    
